# coding: utf-8
import pandas as pd
import numpy as np

# 三个字段 name, site, age
nme = ["Google", "Runoob", "Taobao", "Wiki"]
st = ["www.google.com", "www.说的都是.com", "www.taobao.com", "www.wikipedia.org"]
ag = [90, 40, 80, 98]

# 字典
dict = {'name': nme, 'site': st, 'age': ag}

df = pd.DataFrame(dict)

# 保存 dataframe
df.to_csv('site.csv')


def _readCsv(filename):
    df = pd.read_csv(filename, encoding='GBK')
    print(df.head(5))
    print(df.shape)

    return df


def read_template():
    filename = r'./site.csv'
    ## 文档格式包含中文，编码需utf-8
    df = pd.read_csv(filename, encoding="utf-8").values.tolist()
    print(df)
    # df = pd.read_csv(filename)

def to_execl(data, items, fileName):

    # data = [{'data':1,'num':2},{'data':5,'num':2}]

    df = pd.DataFrame(data, columns=items)

    df.to_excel(fileName, index=False)

data = [{'data':1,'num':2},{'data':5,'num':2}]
items = ['data','num']
# data[0].keys()
to_execl(data,items,"unInstallHids.xlsx")

read_template()
